<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  props: {
    info: { type: Object, required: true },
  },
});
</script>

<template>
  <view class="news-item">
    <view class="news-item-video" v-if="info.type === 2">
      <image class="news-item-video2" :src="info.pic_url" mode="aspectFill" />
      <image
        class="news-item-video3"
        src="@/package/other/static/news-video.png"
      />
    </view>

    <view class="news-item-wrapper">
      <view class="news-item-content">
        <view
          class="news-item-title"
          :style="{ '-webkit-line-clamp': info.type === 2 ? 1 : 2 }"
        >
          <text class="news-item-type">{{ info.cate_name }}</text>
          {{ info.title }}
        </view>
        <view
          class="news-item-date"
          :style="{ marginTop: info.type === 2 ? '10rpx' : '20rpx' }"
        >
          {{ info.cdate }}
        </view>
      </view>

      <image
        class="news-item-img"
        v-if="info.type !== 2 && info.pic_url"
        :src="info.pic_url"
        mode="aspectFill"
      />
    </view>
  </view>
</template>

<style lang="scss">
.news-item {
  border-radius: 20rpx;
  background-color: #ffffff;

  .news-item-video {
    position: relative;
  }

  .news-item-video2 {
    display: block;
    width: 100%;
    height: 388rpx;
    border-radius: 20rpx 20rpx 0 0;
  }

  .news-item-video3 {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 96rpx;
    height: 96rpx;
    transform: translate(-50%, -50%);
  }

  .news-item-wrapper {
    display: flex;
    padding: 20rpx;
  }

  .news-item-content {
    flex-grow: 1;
    min-width: 0;
  }

  .news-item-title {
    font-size: 30rpx;
    color: #333333;
    line-height: 42rpx;
    font-weight: bold;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .news-item-type {
    display: inline-block;
    padding: 0 8rpx;
    font-size: 24rpx;
    color: #f36514;
    line-height: 36rpx;
    font-weight: 400;
    border-radius: 4rpx;
    background-color: rgba(255, 237, 224, 0.6);
  }

  .news-item-date {
    font-size: 24rpx;
    color: #bbbbbb;
    line-height: 34rpx;
  }

  .news-item-img {
    flex-shrink: 0;
    width: 190rpx;
    height: 140rpx;
    margin-left: 30rpx;
    border-radius: 10rpx;
  }
}
</style>